<template>
	<view class="container">
		<view class="topnav flex plr-30">
			<view class="nav_title flex">
				<image src="../../static/chip/back.png" @click="backfn" mode="widthFix"></image>
				新的联系人
			</view>
			<view class="" @click="addgroup">添加群聊</view>
		</view>
		<u-index-list :scrollTop="scrollTop">
			<view v-for="(item, index) in indexList" :key="index">
				<!-- <u-index-anchor :index="item" /> -->
				<!-- <view class="list-cell">
					列表1
				</view>
				<view class="list-cell">
					列表2
				</view> -->
			</view>
		</u-index-list>
		<view class="groupChat">
			<view class="chatItem plr-20 ptb-20 flex flex-start" v-for="item in info">
				<image :src="'http://im.ezongguan.com/static/photo/'+item.photo_path " mode=""></image>
				<view class="ml-20" style="width: 80%;">
					<view class="">{{item.show_name}}</view>
					<view class="size-26 number" style="color: #7d7d72;">{{item.last_msg}}</view>
				</view>
			</view>
		</view>
		<view class="nonebox">
			<image src="../../static/home/2m.png" mode="widthFix"></image>
			<view class="">暂无群聊</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info:'',
				number:'',
				keyword: '',
				scrollTop: 0,
				indexList: ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U",
					"V", "W", "X", "Y", "Z"
				],
			}
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		onLoad(options) {
			this.init()
		},
		methods: {
			init(){
				var params ={
					_token:uni.getStorageSync('im_token'),
					_agent_id:'1',
					type:'1'
				}
				uni.request({
					url: ` http://im.ezongguan.com/im/get/chatList`,
					method: 'POST',
					data: params,
					success: (res) => {
						this.info=res.data.data
						for(let i=0;i<this.info.length;i++){
							this.info[i].last_msg=this.info[i].last_msg.slice(0,this.info[i].last_msg.length-5)
							console.log(this.info.last_msg)
						}
						console.log(this.info)
					},
				})
			},
			addgroup(){
				uni.navigateTo({
					url:'/pages/chip/group_chat'
				})
			},
			backfn(){
				uni.navigateBack({})
			},
		},
		
	}
</script>

<style lang="less" scoped>
.number{
	white-space: nowrap;
	overflow: hidden;
  text-overflow: ellipsis;
}
.container{
	width: 100%;
	.topnav{
		width: 100%;
		height: 100rpx;
		line-height: 100rpx;
		background-color: rgb(236, 241, 247);
		image{
			width: 40rpx;
		}
		.nav_title{
		}
	}
	.groupChat{
		.chatItem{
			width: 100%;
			border-bottom: 1rpx solid #F5F5F5;
			image{
				width: 80rpx;
				height: 80rpx;
			}
		}
	}
	.nonebox{
		text-align: center;
		margin-top: 200rpx;
		image{
			width: 50%;
		}
	}
}
</style>
